package git.soulbgm.socket;

import io.netty.channel.Channel;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author SoulBGM
 * @date 2021-03-29
 */
public class TcpConnection {

    /**
     * key: channel id shortText value: Channel
     */
    private static final Map<String, Channel> CONNECTION_MAP = new ConcurrentHashMap<>();

    public static void put(Channel channel) {
        String id = channel.id().asShortText();
        CONNECTION_MAP.put(id, channel);
    }

    public static void remove(Channel channel) {
        if (channel != null) {
            String id = channel.id().asShortText();
            CONNECTION_MAP.remove(id);
        }
    }
}
